package ru.nsu.fit.client.core.soap.server_info;

import org.ksoap2.serialization.SoapObject;
import ru.nsu.fit.client.core.soap.SOAPExecutor;

public class ServerInfo {
    private static final String WSDL_NAME = "server_info";
    private static final String METHOD_NAME = "getServerInfo";
    private static final String NAMESPACE = "http://server_info.ws.fit.nsu.ru/";
	
	public static ServerInfoOutput execute(final String serverLocation) throws Exception
	{
		String wsdlLocation = serverLocation + WSDL_NAME + "?wsdl";
		
		SoapObject response = SOAPExecutor.executeSOAP(wsdlLocation, NAMESPACE, METHOD_NAME, null);
			
		ServerInfoOutput out = new ServerInfoOutput();
		out.setDate(response.getPropertyAsString("date"));
		out.setVersion(response.getPropertyAsString("version"));
		out.setInfo(response.getPropertyAsString("info"));
		
		return out;
	}
}
